package com.corpgovernment.organization.service.impl;

import com.corpgovernment.api.organization.bo.LandmarkBO;
import com.corpgovernment.api.organization.bo.SearchLandmarkRequestBO;
import com.corpgovernment.api.organization.bo.SearchLandmarkResponseBO;
import com.corpgovernment.organization.convert.LandmarkConvert;
import com.corpgovernment.organization.dataloader.db.LandmarkLoader;
import com.corpgovernment.organization.entity.db.MbLandmark;
import com.corpgovernment.organization.service.ILandmarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 地标service
 */
@Service
public class LandmarkServiceImpl implements ILandmarkService {

	@Autowired
	private LandmarkLoader landmarkLoader;
	@Autowired
	private LandmarkConvert landmarkConvert;

	/**
	 * 地标查询
	 *
	 * @param request
	 * @return
	 */
	@Override
	public SearchLandmarkResponseBO search(SearchLandmarkRequestBO request) {
		SearchLandmarkResponseBO response = new SearchLandmarkResponseBO();
		MbLandmark queryParam = landmarkConvert.convertFromBo(request);
		if (queryParam == null) {
			return response;
		}
		List<MbLandmark> landmarkList = landmarkLoader.select(queryParam);
		List<LandmarkBO> queryResult = landmarkConvert.convertToBo(landmarkList);
		response.setLandmarkList(queryResult);
		return response;
	}
}
